<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

class Webcity_m extends FOX_Model
{

	function __construct ()
	{
		parent::__construct();
        $this->config->load('webcityset');
	}

	public function get_all_citys(){
        $this->db->select('*');
        $this->db->from('citys');
        $query = $this->db->get();
        return $query->result_array();
    }

     public function sava_citys($id,$data){

        $this->db->where('city_id',$id);
        $this->db->update('citys', $data);
        return ($this->db->affected_rows() > 0) ? TRUE : FALSE;
    }

    public function add_citys($data){

        $this->db->insert('citys',$data);
        return ($this->db->affected_rows() > 0) ? TRUE : FALSE;
    }

    public function get_webcity_by_city_id($city_id){
        $this->db->select('*');
        $query = $this->db->where('city_id',$city_id)->get('citys');
        return $query->row_array();
    }
    public function del_citys($id){
        // $this->db->where($where)->delete('citys');
        // return ($this->db->affected_rows() > 0) ? TRUE : FALSE;
        $this->db->where('city_id',$id)->delete('citys');
    }
    public function get_city_type(){
        $city_type=$this->city_type=explode('|', $this->config->item('city_type'));
        // var_dump($this->web_category);exit;
        $city_type_text=$this->city_type_text=explode('|', $this->config->item('city_type_text'));
       $data['city_type']=array_combine($city_type,$city_type_text);
       return  $data;
    }
    public function del_citys_by_city_ids($where){
        $this->db->where($where)->delete('citys');
        return ($this->db->affected_rows() > 0) ? TRUE : FALSE;
    }
}
